<template>
    <div class="run">
        <DashHeader/>
        <el-main>
        <h3>
            选择测试参数</h3>
            <h4>测试产品：
            <el-select name="product" v-model="product">
                <el-option label="EVI" value="evicloud" >EVI</el-option>
                <el-option label="数字矿山" value="ddm" >数字矿山</el-option>
            </el-select> </h4>
            
            <h4>测试环境： 
            <el-select name="env" v-model="env">
                <el-option label="测试环境" value="test" >测试环境</el-option>
                <el-option label="集成环境" value="instrg" >集成环境</el-option>
            </el-select></h4>

            <h4>       
            测试微服务：
             <el-checkbox-group v-model="module">
        <el-checkbox label="evi_portal_device" name="type"></el-checkbox>
        <el-checkbox label="evi_portal_web" name="type"></el-checkbox>
        <el-checkbox label="evi_portal_generatefile" name="type"></el-checkbox>
        <el-checkbox label="evi_rule_engine" name="type"></el-checkbox>
        <el-checkbox label="evi_portal_mapi" name="type"></el-checkbox>
        <el-checkbox label="evi_rule_engine" name="type"></el-checkbox>
        <el-checkbox label="evi_rule_engine" name="type"></el-checkbox>
      </el-checkbox-group> 
            <!-- <el-select name="module" v-model="module">
                <el-option value="evi_portal_deivce" >device</el-option>
                <el-option value="evi_portal_web" >web</el-option>
            </el-select> --></h4>        
            <h4>            
            用例优先级： 
            <el-select name="serverity" v-model="serverity">
                <el-option value="critical" >critical</el-option>
                <el-option value="normal" >normal</el-option>
                  <el-option value="minor" >minor</el-option>
                <el-option value="critical,normal,minor" >all</el-option>
            </el-select></h4>  
                    <h4>            
            通知邮箱： 
            <el-input  name="email" v-model="email"  style="width:300px">
            </el-input></h4> 

                <el-button type="primary" @click="runTest">执行测试</el-button>
      
        </el-main>
    </div>

</template>

<script>
import  DashHeader from '@/components/DashHeader'
//import axios from 'axios'

export default {
   name: 'Run',
   components: {
       DashHeader
   },
   data() {
       return {
           product: 'evicloud',
           env: 'test',
           module: 'device',
           serverity: 'critical',
           planid: '',
           email: ''
       }
   },
   methods: {
       async runTest() {
           var url = "/api/v1/operation/planjenkins";
           await this.$http.post(url,{            
                    'project':this.product,
                    'runningEnv':this.env,
                    'module':this.module,
                    'caseServerity': this.serverity,
                    'mailReceiver': this.email
                     })
                     .then(resp => {
               window.console.log(resp.data)
               this.planid = resp.data
           })
           //提示执行成功
           var message =  '测试ID为：' + this.planid
           this.$alert(message, '测试开始执行', {
          confirmButtonText: '确定',
            callback: () => {
            this.$message({
              type: 'info',
              message: `开始测试`,
            })
          }, 
        })
        
       }
   }
}
</script>